package com.zkny.zknyerp.service.impl;

import com.zkny.zknyerp.mapper.UserMapper;
import com.zkny.zknyerp.model.User;
import com.zkny.zknyerp.service.UserService;
import com.zkny.zknyerp.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import tk.mybatis.mapper.entity.Example;

import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.List;

/**
 * 用户服务接口实现类
 */
@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;


    /**
     * 查询用户
     *
     * @param username
     * @return
     */
    public User queryUser(String username) {
        Example example = new Example(User.class);
        example.createCriteria().andEqualTo("username", username);
        List<User> list = userMapper.selectByExample(example);
        if (ObjectUtils.isEmpty(list)) {
            return null;
        }
        User user = list.get(0);
        return user;
    }

}
